From d555ae0e52dd5f74139e23b172018213b4e4e232 Mon Sep 17 00:00:00 2001 From: robertl Date: Fri, 11 Apr 2008 17:37:53 +0000 Subject: [PATCH] Unicsv: add n/s and e/w options to reader. --- gpsbabel/unicsv.c | 18 ++++++++++++++++-- gpsbabel/xmldoc/formats/unicsv.xml | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/gpsbabel/unicsv.c b/gpsbabel/unicsv.c index 964c78ca3..3fbb54f7f 100644 --- a/gpsbabel/unicsv.c +++ b/gpsbabel/unicsv.c @@ -86,6 +86,8 @@ typedef enum { fld_hour, fld_min, fld_sec, + fld_ns, + fld_ew, fld_garmin_city, fld_garmin_postal_code, fld_garmin_state, @@ -187,6 +189,8 @@ static field_t fields_def[] = { { "year", fld_year, STR_LEFT }, { "month", fld_month, STR_LEFT }, { "day", fld_day, STR_LEFT }, + { "n/s", fld_ns, STR_ANY }, + { "e/w", fld_ew, STR_ANY }, /* garmin specials */ { "addr", fld_garmin_addr, STR_ANY }, @@ -527,6 +531,8 @@ unicsv_parse_one_line(char *ibuf) double d; struct tm ymd; int src_datum = unicsv_datum_idx; + int ns = 1; + int ew = 1; wpt = waypt_new(); wpt->latitude = unicsv_unknown; @@ -545,7 +551,6 @@ unicsv_parse_one_line(char *ibuf) s = lrtrim(s); if (! *s) continue; /* skip empty columns */ - switch(unicsv_fields_tab[column]) { case fld_time: @@ -562,10 +567,12 @@ unicsv_parse_one_line(char *ibuf) case fld_latitude: human_to_dec( s, &wpt->latitude, &wpt->longitude, 1 ); + wpt->latitude = wpt->latitude * ns; break; case fld_longitude: human_to_dec( s, &wpt->latitude, &wpt->longitude, 2 ); + wpt->longitude = wpt->longitude * ew; break; case fld_shortname: @@ -795,7 +802,14 @@ unicsv_parse_one_line(char *ibuf) case fld_datetime: /* not implemented */ break; - + case fld_ns: + ns = tolower(s[0]) == 'n' ? 1 : -1; + wpt->latitude *= ns; + break; + case fld_ew: + ew = tolower(s[0]) == 'e' ? 1 : -1; + wpt->longitude *= ew; + break; case fld_garmin_city: case fld_garmin_postal_code: case fld_garmin_state: diff --git a/gpsbabel/xmldoc/formats/unicsv.xml b/gpsbabel/xmldoc/formats/unicsv.xml index 69a19f94d..c4f0cd56b 100644 --- a/gpsbabel/xmldoc/formats/unicsv.xml +++ b/gpsbabel/xmldoc/formats/unicsv.xml @@ -23,6 +23,7 @@ depth = Depth desc = Description ele = Elevation (in meters) of the point + e/w = 'e' for eastern hemisphere, 'w' for western fix = 3d, 2d, etc. geschw = Geschwindigkeit (speed) hdop = Horizontal dilution of precision @@ -32,6 +33,7 @@ lat = Latitude lon = Longitude name = Waypoint name ("Shortname") + n/s = 'n' for northern hemisphere, 's' for southern notes = Notes pdop = Position dilution of precision prox = Proximity -- 2.30.2